<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.paradise.dms.util.ExcelFieldsToValidate"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	List errList = (List) request.getAttribute("errorStudentInfoList");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>My JSP 'errordata.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/uploadAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type="text/javascript">
		
			var num = <%=errList.size()%>;  //出错记录的行数
			//todo,在页面上出错行被修改后的样式变化
			/*
			function  whemChanged(obj){
				alert("wc");
				obj.style.backgroundColor = "green";
			}
			*/
			//为出错元素添加样式
			function addClass(rowNum){
			    var tmp = locatePosition($('errorInfo'+rowNum).value);
				//$(tmp + rowNum).attachEvent("onChange",whemChanged($(tmp + rowNum))); //有问题
				$(tmp + rowNum).style.backgroundColor = "red";
			
			}
			
			//定位错误元素的位置
			function locatePosition(errorInfo){
				var p = 'right';  //出错元素标记,right初始值,表示没有出错
				errorInfo = errorInfo.substr(0,2);
				//alert(errorInfo);
				switch(errorInfo){
					case "学号": p = 'no';break;
					case "姓名": p = 'name';break;
					case "入学": p = 'enrollyear';break;
					case "学制": p = 'eduyear';break;
					case "身份": p = 'entitycardno';break;
					case "学院": p = 'college';break;
					case "专业": p = 'major';break;
					case "班级": p = 'class';break;
					case "性别": p = 'gender';break;
					case "生日": p = 'birthday';break;
					case "民族": p = 'ethnic';break;
					case "政治": p = 'politics';break;
					case "生源": p = 'birthplace';break;
					case "毕业": p = 'middleschool';break;
					case "第二": p = 'secondlanguage';break;
					case "层次": p = 'type';break;
				}
				//alert(p)
				return p;
			}
			
			function CreateLine(){
			//alert("baaab");
			<%
				
					for(int a = 0;a<errList.size();a++){
						//int b = a + 1;
						out.println("myrow=$('errorTable').insertRow("+a+");");
						out.println("myrow.id= 'tr"+a+"';");
						ExcelFieldsToValidate errRecord= (ExcelFieldsToValidate)errList.get(a);
						
						
						out.println("c=myrow.insertCell(0);");
						out.println("c.innerHTML=\"<input type='text' id='errorInfo"+a+"' value='"+errRecord.getErrorInfo()+"' />\";");
						out.println("c=myrow.insertCell(1);");
						out.println("c.innerHTML=\"<input type='text' id='no"+a+"' value='"+errRecord.getStudentno()+"' />\";");
						out.println("c=myrow.insertCell(2);");
						out.println("c.innerHTML=\"<input type='text' id='name"+a+"' value='"+errRecord.getStudentname()+"' />\";");
						out.println("c=myrow.insertCell(3);");
						out.println("c.innerHTML=\"<input type='text' id='enrollyear"+a+"' value='"+errRecord.getStudentenrollyear()+"' />\";");
						out.println("c=myrow.insertCell(4);");
						out.println("c.innerHTML=\"<input type='text' id='eduyear"+a+"' value='"+errRecord.getStudenteducationyears()+"' />\";");
						out.println("c=myrow.insertCell(5);");
						out.println("c.innerHTML=\"<input type='text' id='entitycardno"+a+"' value='"+errRecord.getStudentidentitycardno()+"' />\";");
						out.println("c=myrow.insertCell(6);");
						out.println("c.innerHTML=\"<input type='text' id='college"+a+"' value='"+errRecord.getCollegeinfoid()+"' />\";");
						out.println("c=myrow.insertCell(7);");
						out.println("c.innerHTML=\"<input type='text' id='major"+a+"' value='"+errRecord.getMajorinfoid()+"' />\";");
						out.println("c=myrow.insertCell(8);");
						out.println("c.innerHTML=\"<input type='text' id='class"+a+"' value='"+errRecord.getStudentclass()+"' />\";");
						out.println("c=myrow.insertCell(9);");
						out.println("c.innerHTML=\"<input type='text' id='gender"+a+"' value='"+errRecord.getStudentgender()+"' />\";");
						out.println("c=myrow.insertCell(10);");
						out.println("c.innerHTML=\"<input type='text' id='birthday"+a+"' value='"+errRecord.getStudentbirthday()+"' />\";");
						out.println("c=myrow.insertCell(11);");
						out.println("c.innerHTML=\"<input type='text' id='ethnic"+a+"' value='"+errRecord.getStudentethnic()+"' />\";");
						out.println("c=myrow.insertCell(12);");
						out.println("c.innerHTML=\"<input type='text' id='politics"+a+"' value='"+errRecord.getStudentpolitics()+"' />\";");
						out.println("c=myrow.insertCell(13);");
						out.println("c.innerHTML=\"<input type='text' id='birthplace"+a+"' value='"+errRecord.getStudentbirthplace()+"' />\";");
						out.println("c=myrow.insertCell(14);");
						out.println("c.innerHTML=\"<input type='text' id='middleschool"+a+"' value='"+errRecord.getStudentmiddleschool()+"' />\";");
						out.println("c=myrow.insertCell(15);");
						out.println("c.innerHTML=\"<input type='text' id='secondlanguage"+a+"' value='"+errRecord.getStudentsecondlanguage()+"' />\";");
						out.println("c=myrow.insertCell(16);");
						out.println("c.innerHTML=\"<input type='text' id='type"+a+"' value='"+errRecord.getStudenttype()+"' />\";");
						
						out.println("addClass("+a+");");
					}
				
				%>

			}
			
			var list = new Array();    //更改后的excel学生数据
			function submitUpdate(){
				alert("here");
				for(var a = 0; a<num;a++){
					list[a] = new Array();
					list[a][0] = $('errorInfo'+a).value;
					list[a][1] = $('no'+a).value;
					list[a][2] = $('name'+a).value;
					list[a][3] = $('enrollyear'+a).value;
					list[a][4] = $('eduyear'+a).value;
					list[a][5] = $('entitycardno'+a).value;
					list[a][6] = $('college'+a).value;
					list[a][7] = $('major'+a).value;
					list[a][8] = $('class'+a).value;
					list[a][9] = $('gender'+a).value;
					list[a][10] = $('birthday'+a).value;
					list[a][11] = $('ethnic'+a).value;
					list[a][12] = $('politics'+a).value;
					list[a][13] = $('birthplace'+a).value;
					list[a][14] = $('middleschool'+a).value;
					list[a][15] = $('secondlanguage'+a).value;
					list[a][16] = $('type'+a).value;
					list[a][17] = a;  //行号标记
				}
				uploadAction.checkUpdatedErrordata(list,checkUpdatedErrordataCallback);
			}
			var checkUpdatedErrordataCallback = function checkUpdatedErrordataCallbackFunc(l){
				for(var a = 0;a<l.length;a++){
					if(l[a][17] == "-1"){
						 $('errorTable').deleteRow($('tr'+a).rowIndex);
					}else{
						 alert(l[a].length+"= l["+a+"].length且"+l[a][0]);
						 $('errorInfo'+a).value = l[a][0];
						 $('no'+a).value=l[a][1] ;
						 $('name'+a).value=l[a][2] ;
						 $('enrollyear'+a).value=l[a][3] ;
						 $('eduyear'+a).value=l[a][4];
						 $('entitycardno'+a).value=l[a][5] ;
						 $('college'+a).value=l[a][6];
						 $('major'+a).value=l[a][7];
						 $('class'+a).value=l[a][8];
						 $('gender'+a).value=l[a][9] ;
						 $('birthday'+a).value=l[a][10];
						 $('ethnic'+a).value=l[a][11] ;
						 $('politics'+a).value=l[a][12];
						 $('birthplace'+a).value=l[a][13];
						 $('middleschool'+a).value=l[a][14] ;
						 $('secondlanguage'+a).value=l[a][15] ;
					     $('type'+a).value=l[a][16];
					     addClass(a);
					}
				}
			
			}
		
  </script>
	</head>

	<body>
		<table id="errorTable" border="1">
		
		</table>
		<div style="text-align: right; width: 90%;">
			<input type="button" name="submit" id="submit" value="提交更改"
				onclick="submitUpdate()" />
		</div>










		<script type="text/javascript">
     	document.onLoad = CreateLine();
  	</script>
	</body>


</html>
